home *** CD-ROM | disk | FTP | other *** search
- { backgrnd.pas -- Use custom brush to paint window background }
-
- program Backgrnd;
-
- {$R brush.res}
-
- uses WinTypes, WinProcs, WObjects;
-
- const
-
- id_Pattern = 200; { Resource ID of any 8-by-8 bitmap }
-
- type
-
- BackgrndApplication = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- PBackgrndWindow = ^BackgrndWindow;
- BackgrndWindow = object(TWindow)
- Pattern: HBrush; { Handle to brush made from bitmap }
- constructor Init(AParent: PWindowsObject; ATitle: PChar);
- destructor Done;
- virtual;
- function GetClassName: PChar;
- virtual;
- procedure GetWindowClass(var AWndClass: TWndClass);
- virtual;
- end;
-
-
- { BackgrndApplication }
-
- {- Initialize BackgrndApplication object's window }
- procedure BackgrndApplication.InitMainWindow;
- begin
- MainWindow := New(PBackgrndWindow, Init(nil, 'Backgrnd'))
- end;
-
-
- { BackgrndWindow }
-
- {- Construct BackgrndWindow object }
- constructor BackgrndWindow.Init(AParent: PWindowsObject; ATitle: PChar);
- var
- H: HBitmap;
- begin
- TWindow.Init(AParent, ATitle);
- H := LoadBitmap(HInstance, PChar(id_Pattern));
- Pattern := CreatePatternBrush(H);
- DeleteObject(H)
- end;
-
- {- Destroy BackgrndWindow object and the custom brush }
- destructor BackgrndWindow.Done;
- begin
- DeleteObject(Pattern);
- TWindow.Done
- end;
-
- function BackgrndWindow.GetClassName: PChar;
- begin
- GetClassName := 'BkgWin'
- end;
-
- procedure BackgrndWindow.GetWindowClass(var AWndClass: TWndClass);
- begin
- TWindow.GetWindowClass(AWndClass);
- AWndClass.hbrBackground := Pattern
- end;
-
- var
-
- BackgrndApp: BackgrndApplication;
-
- begin
- BackgrndApp.Init('BackgrndApp');
- BackgrndApp.Run;
- BackgrndApp.Done
- end.
-
-
- {--------------------------------------------------------------
- Copyright (c) 1991 by Tom Swan. All rights reserved.
- Revision 1.00 Date: 2/26/1991
- ---------------------------------------------------------------}
-